<?php  if (!defined("IS_INITPHP")) exit("Access Denied!");  /* INITPHP Version 1.0 ,Create on 2016-04-11 20:51:56, compiled from D:\phpStudy\WWW\Frame/app/web/template/admin/module_edit_form.htm */ ?>
  <div class="am-tabs am-margin" data-am-tabs>
    <ul class="am-tabs-nav am-nav am-nav-tabs">
      <li class="am-active"><a href="#tab1">基本信息</a></li>
    </ul>
    <div class="am-tabs-bd">
      <div class="am-tab-panel am-fade am-in am-active" id="tab1">
      	<?php foreach  ( $view_fields as $key=>$val ) { ?>
      		<?php if  ($val['type'] == 'select') { ?>
		        <div class="am-g am-margin-top">
		          <div class="am-u-sm-4 am-u-md-2 am-text-right"><?php echo $val['name'];?></div>
		          <div class="am-u-sm-8 am-u-md-10">
		            <select data-am-selected="{btnSize: 'xs',maxHeight: 150,btnStyle: 'secondary'}" name="<?php echo $key;?>">
		              <?php foreach ($select_fields[$key] as $k=>$v ) { ?>		
		              <option value="<?php echo $k;?>" <?php if ($k == $model[$key]) { ?>selected<?php } ?> ><?php echo $v;?></option>
		              <?php } ?>
		            </select>
		          </div>
		        </div>
		    <?php } elseif  ($val['type'] == 'treelist') { ?> 
			    <div class="am-g am-margin-top">
			      <div class="am-u-sm-4 am-u-md-2 am-text-right"><?php echo $val['name'];?></div>
			      <div class="am-u-sm-8 am-u-md-10">
			        <select data-am-selected="{btnSize: 'xs',maxHeight: 200,btnStyle: 'success'}" name="<?php echo $key;?>">
			       		<?php echo $treelist_fields[$key];?>
			        </select>
			      </div>
			    </div>
			<?php } elseif  ($val['type'] == 'text') { ?>
			  <div class="am-g am-margin-top">
	            <div class="am-u-sm-4 am-u-md-2 am-text-right">
	              <?php echo $val['name'];?>
	            </div>
	            <div class="am-u-sm-8 am-u-md-4">
	              <input type="text" class="am-input-sm" name="<?php echo $key;?>"  value="<?php echo $model[$key];?>">
	            </div>
	            <div class="am-hide-sm-only am-u-md-6"><?php echo $val['note'];?></div>
	          </div>
			<?php } elseif  ($val['type'] == 'password') { ?>
			  <div class="am-g am-margin-top">
	            <div class="am-u-sm-4 am-u-md-2 am-text-right">
	              <?php echo $val['name'];?>
	            </div>
	            <div class="am-u-sm-8 am-u-md-4">
	              <input type="password" class="am-input-sm" name="<?php echo $key;?>"  value="<?php echo $model[$key];?>">
	            </div>
	            <div class="am-hide-sm-only am-u-md-6"><?php echo $val['note'];?></div>
	          </div>
	        <?php } elseif  ($val['type'] == 'autoinput') { ?>
			  <div class="am-g am-margin-top">
	            <div class="am-u-sm-4 am-u-md-2 am-text-right">
	              <?php echo $val['name'];?>
	            </div>
	            <div class="am-u-sm-8 am-u-md-4">
	              <input type="text"  name="<?php echo $key;?>"  autocomplete="off" value = "<?php echo $model[$key];?>">
	            </div>
	            <div class="am-hide-sm-only am-u-md-6"><?php echo $val['note'];?></div>
	          </div>
	          <script type="text/javascript">

				$("input").autopoint({url:'<?php echo $val['dataurl'];?>',submit:["action1", "action2"]});
	          </script>
			<?php } elseif  ($val['type'] == 'datetime') { ?>
			  <div class="am-g am-margin-top">
	            <div class="am-u-sm-4 am-u-md-2 am-text-right">
	              <?php echo $val['name'];?>
	            </div>
	            <div class="am-u-sm-8 am-u-md-4">
	              <input type="text" class="am-input-sm" name="<?php echo $key;?>"  id="<?php echo $key;?>" value="<?php echo $model[$key];?>">
	            </div>
	            <div class="am-hide-sm-only am-u-md-6"><?php echo $val['note'];?></div>
	          </div>

          <script>
	            var <?php echo $key;?> = {
	                elem: '#<?php echo $key;?>',
	                format: 'YYYY/MM/DD hh:mm:ss',
	                istime: true
	            };
	            laydate(<?php echo $key;?>);
          </script>
			<?php } elseif  ($val['type'] == 'textarea') { ?>
			  <div class="am-g am-margin-top">
	            <div class="am-u-sm-4 am-u-md-2 am-text-right">
	              <?php echo $val['name'];?>
	            </div>
	            <div class="am-u-sm-8 am-u-md-4">
	            	<textarea name="<?php echo $key;?>"  id="<?php echo $key;?>"> <?php echo $model[$key];?></textarea>
	            </div>
	            <div class="am-hide-sm-only am-u-md-6"><?php echo $val['note'];?></div>
	          </div>
			<?php } elseif  ($val['type'] == 'tag') { ?>
			  <div class="am-g am-margin-top">
	            <div class="am-u-sm-4 am-u-md-2 am-text-right">
	              <?php echo $val['name'];?>
	            </div>
	            <div class="am-u-sm-8 am-u-md-6">
	            	<div data-tags-input-name="<?php echo $key;?>" id="<?php echo $key;?>Box"></div>
	            </div>
	            <div class="am-hide-sm-only am-u-md-4"><?php echo $val['note'];?></div>
	          </div>
			  <script>
				$(function() {
						var tagarr = '<?php echo $model[$key];?>'.split(',');
				   		var  t = $("#<?php echo $key;?>Box").tagging();
				   		t[0].tagging('add',tagarr);
				});
			  </script>
			<?php } elseif  ($val['type'] == 'richtext') { ?>
			  <div class="am-g am-margin-top">
	            <div class="am-u-sm-4 am-u-md-2 am-text-right">
	              <?php echo $val['name'];?>
	            </div>
	            <div class="am-u-sm-8 am-u-md-10">
			        <script id="<?php echo $key;?>" name="<?php echo $key;?>" type="text/plain"><?php echo $model[$key];?></script>
	            </div>
	            
	          </div>
				<script type="text/javascript" src="./static/assets/js/ueditor/ueditor.config.js"></script>
		    	<!-- 编辑器源码文件 -->
			    <script type="text/javascript" src="./static/assets/js/ueditor/ueditor.all.js"></script>
			    <!-- 实例化编辑器 -->
			    <script type="text/javascript">
			        var editor = UE.getEditor('<?php echo $key;?>');
			    </script>
			<?php } elseif  ($val['type'] == 'image') { ?>
			  <div class="am-g am-margin-top">
	            <div class="am-u-sm-4 am-u-md-2 am-text-right">
	              <?php echo $val['name'];?>
	            </div>
	            <div class="am-u-sm-8 am-u-md-4">	              
		            <div class="am-form-group am-form-file">
					  <i class="am-icon-cloud-upload"></i> 选择要上传的图片
					  <input type="file" id="<?php echo $key;?>_file" name="<?php echo $key;?>_file" data-url="<?php echo $val['uploadurl'];?>">
					  <input type="hidden" name="<?php echo $key;?>" value="<?php echo $model[$key];?>">
					</div>
					<div id="image-list">
						<img src="<?php echo WEB_PATH;?><?php echo $model[$key];?>" width="<?php echo $val['width'];?>px" id="<?php echo $key;?>_preview" />
					</div>
	            </div>
	            <div class="am-hide-sm-only am-u-md-6"><?php echo $val['note'];?></div>
	          </div>
			<script>
			$(function() {
			    $('#<?php echo $key;?>_file').fileupload({
			        dataType: 'json',
			        formData:{filefield:'<?php echo $key;?>_file'},
			        done: function (e, data) {
			          if(data.result.status == 0 ){
				          $("#<?php echo $key;?>_preview").attr('src',data.result.data.url);
				          $(":input[name='<?php echo $key;?>']").val(data.result.data.filename);
			          }else{
			          	 alert(data.result.message);
			          }	
			        }    
			    });
			});
			</script>
			<?php } elseif  ($val['type'] == 'file') { ?>
				<div class="am-g am-margin-top">
		            <div class="am-u-sm-4 am-u-md-2 am-text-right">
		              <?php echo $val['name'];?>
		            </div>
		            <div class="am-u-sm-8 am-u-md-4">	              
			            <div class="am-form-group am-form-file">
						  <i class="am-icon-cloud-upload"></i> 选择要上传的文件
						  <input type="file" id="<?php echo $key;?>_file" name="<?php echo $key;?>_file" data-url="<?php echo $val['uploadurl'];?>">
						  <input type="hidden" name="<?php echo $key;?>" value="<?php echo $model[$key];?>">
						</div>
						<div id="<?php echo $key;?>_div" class="am-progress am-progress-striped am-progress-sm am-active " style="display:none">
						    <div id="<?php echo $key;?>_bar" class="am-progress-bar am-progress-bar-secondary"  style="width: 0%;"></div>
						</div>
						<div id="<?php echo $key;?>-list" style="display:none">
							<div id="<?php echo $key;?>_name" />默认文件</div>
						</div>
		            </div>
		            <div class="am-hide-sm-only am-u-md-6"><?php echo $val['note'];?></div>
	            </div>
            <script>
			$(function() {
			    $('#<?php echo $key;?>_file').fileupload({
			        dataType: 'json',
			        formData:{filefield:'<?php echo $key;?>_file'},
			        done: function (e, data) {
			          if(data.result.status == 1 ){
				          $("#<?php echo $key;?>_name").html(data.result.data.filename);
				          $(":input[name='<?php echo $key;?>']").val(data.result.data.url);
				          $("#<?php echo $key;?>-list").show();
			          }else{
			          	alert(data.result.message);
			          }	
			        },
			        progressall: function (e, data) {//设置上传进度事件的回调函数 
	                    var progress = parseInt(data.loaded / data.total * 100);  
	                    $('#<?php echo $key;?>_div').css(
	                    	'display',
	                    	'block'
                    	);
	                    $('#<?php echo $key;?>_bar').css(  
	                        'width',  
	                        progress + '%'  
	                    );  
	                }
			    });
			});
			</script>
			<?php } elseif  ($val['type'] == 'checkbox') { ?>
				<div class="am-g am-margin-top">
		          <div class="am-u-sm-4 am-u-md-2 am-text-right"><?php echo $val['name'];?></div>
		          <div class="am-u-sm-8 am-u-md-10">
		            <div class="am-btn-group" data-am-button="">
		              <?php foreach ($checkbox_fields[$key] as $k=>$v ) { ?>		
		              <label class="am-btn am-btn-default am-btn-xs <?php if ( in_array($k, $model[$key])) { ?>am-active<?php } ?>">
		                <input type="checkbox" name="<?php echo $key;?>[]" value="<?php echo $k;?>"  <?php if ( in_array($k, $model[$key])) { ?>checked<?php } ?>  ><?php echo $v;?>
		              </label>
		              <?php } ?>
		            </div>
		          </div>
		        </div>
			<?php } ?> 
        <?php } ?>
        <input type="hidden" name="<?php echo $table_key;?>" value="<?php echo $model[$table_key];?>"/>
      </div>
    </div>
  </div>
  <div class="am-margin">
    <button type="submit" name="submit" class="am-btn am-btn-primary am-btn-xs">提交保存</button>
    <button type="button" class="am-btn am-btn-primary am-btn-xs" onclick="javascript:history.go(-1)">放弃保存</button>
  </div>